#pragma once

#include <d3d9.h>
#include <AntTweakBar.h>


#include "../../Common/Interfaces/IUserInterface.h"
#include "../../Common/Interfaces/IDirect3DHijack.h"

#include "UiHandler.h"


class k_UserInterface
	: public IUserInterface
{
public:
	k_UserInterface();
	~k_UserInterface();

	// IObject
	void* QueryInterface(const GUID& ar_InterfaceGuid);

	// IService
	virtual void Initialize(IServiceLocator& ar_ServiceLocator);
	virtual void Deinitialize();
	virtual bool get_IsInitialized() const;

	// IUserInterface
	virtual IDirect3DDevice9* get_Device() const;
	virtual void set_Device(IDirect3DDevice9* ar_Device_);
	virtual void RenderMenu();

	virtual HHOOK get_GetMessageHook() const;
	virtual bool get_IsMenuModeActive() const;
	virtual void set_MenuModeActiveState(bool ab_State);
	virtual IUiHandler* get_UiHandler() const;

	virtual void set_Active(bool ab_State);
	virtual bool get_Active() const;

	static IServiceLocator& get_ServiceLocator() { return *smr_ServiceLocator_; }

protected:
	virtual void UpdateActivationState();
	virtual bool ProcessUiMessage(HWND ah_Wnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	
private:
	bool mb_Initialized;
	static IServiceLocator* smr_ServiceLocator_;
	IDirect3DHijack* mr_Direct3DHijack_;

	bool mb_Activated;
	bool mb_ActivationSwitchKeyDown;

	int mi_ModificatorKey;
	int mi_Key;
	HCURSOR mh_OldMouseCursor;

	HHOOK mh_GetMessageHook;

	IDirect3DDevice9* mr_Device_;
	IUiHandler* mr_UiHandler_;

	static LRESULT CALLBACK GetMessageProc(int code, WPARAM wParam, LPARAM lParam);
};
